 $LOAD_PATH.unshift File.join(File.dirname(__FILE__),'../..','ext_pr1/lib')
 require 'ext_pr1_v4'

#Übungsblatt für die Programmierpraxis

# List[1,2,3,4,5,6].each {|hallo| puts (hallo*hallo)}
# List[1,2,3,4,5,6].each {|hallo, tschau| if hallo == 5 then puts "Hallo Tim" end}
# List[1,2,3,4,5,6].each {|hallo,haus| haus=hallo+1; puts(hallo);puts(haus)}

#x = "tim"
#
#puts("Hallo, mein Name ist #{x} und ich wohne in Bad Oldesloe.")
#puts("Hallo, mein Name ist " + x + " und ich wohne in Bad Oldesloe.")

#(1..10).to_a.tap {|x| puts("orig : #{x}")}
#val = (1..10).to_a
#puts (val)

#(1..10).to_a.select{|x|x%2==0}.map{|x|x*x}
# 
#(1..10) .tap {|x| puts "orig : #{x}"}
#        .to_a .tap {|x| puts "array: #{x}"}
#        .select {|x| x%2==0} .tap {|x| puts "evens: #{x}"}
#        .map {|x| x*x } .tap {|x| puts "sqrs : #{x}"}

# p((1..10).map{|x| x*2})
#def summe(n); n == 0 ? n : n+summe(n-1) end
#
#puts(summe(100))

#x = 0  
#while x < 10 do
#x = x+1
#puts(x)
#end

#puts((0..10).reduce(:+))
#grades = Hash.new
#
#grades["Bob"] = 82
#grades["Jim"] = 94
#grades["Billy"] = 58
#
#puts grades["Jim"]
#class Array
#   def to_int
#      ret = 0
#      self.each_with_index{|elem,index| ret += 10**(self.size-index-1)*elem }
#      ret
#   end
#end  
#   puts([1,2,3,4].to_int)

module Enumarable
  def partition()
   [] << self.select{|x| yield(x)} << self.reject{|x| yield(x)}
  end
end

p((1..6).partition {|i| i% 2 == 0})